#!/usr/bin/env node

const http = require('http'),
  // mem = reuqire('memory-format'),
  { join } = require('path'),
  fs = require('fs');

http.createServer((res, req) => {
  console.time('TEST');
  let file = join(__dirname, req.url);

  if (!fs.existsSync(file)) {
    res.end(`${req.url} not exists!`)
    return;
  }

  console.log(mem());
  fs.createReadStream(file).pipe(res);
}).listen(8080);